// ignore_for_file: non_constant_identifier_names

import 'package:dsp48_v10/src/tool/assets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';

class ChartPage extends StatefulWidget {
  const ChartPage({super.key});
  @override
  State<ChartPage> createState() => _ChartPageState();
}

class _ChartPageState extends State<ChartPage> {
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constrains) {
        ///计算绘图的真实宽度，高度
        var size = Size(constrains.maxWidth, constrains.maxHeight);
        var padding = const EdgeInsets.only(left: 28, right: 10, top: 5, bottom: 20);
        return Container(
            decoration: boxDecoration(5),
            child: SizedBox.expand(
              child: Stack(
                children: [
                  Positioned(
                      left: 60,
                      right: 40,
                      bottom: 40,
                      top: 0,
                      child: Image.asset(
                        assets.massive,
                        fit: BoxFit.contain,
                      )),
                  Obx(() {
                    var global = globalController.rxModel.value;
                    var sign = global.ch_list[0].sign_list[0];
                    return ChartView(
                        ch: global.current_ch, size: size, padding: padding, minY: sign.min_gain, maxY: sign.max_gain);
                  })
                ],
              ),
            ));
      },
    );
  }
}
